package com.servertrack

import grails.test.mixin.TestFor
import spock.lang.Specification

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Hotel)
class HotelSpec extends Specification {

/*	Hotel hotel
    def setup() {
		mockForConstraintsTests(Hotel)
		hotel = new Hotel(title:"Hotel Avrora",adress:"Tverskaya street",website:"www.avrora.ru",description:"description", dateCreated: new Date("1987/2/10"))
    }

   void testConstraintsTitleUnique() {
		def test = new Hotel(title:"Hotel Avrora",adress:"Sovetckaya street",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
		mockForConstraintsTests(Hotel, [test])

		assertFalse hotel.validate()
		assertEquals 'unique', hotel.errors['title']

		hotel = new Hotel(title:"Hotel Summer Time",adress:"Brinskogo street",website:"www.summer.ru",description:"Summer Timedescription", dateCreated: new Date("2012/5/11"))
		assertTrue hotel.validate()
    }

   void testConstraintsTitleBlank() {
		hotel = new Hotel(title:'',adress:"Sovetckaya street",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
		assertFalse hotel.validate()
		assertEquals 'blank', hotel.errors['title']

		hotel = new Hotel(title:"Hotel Anna",adress:"Sovetckaya street",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
		assertTrue hotel.validate()
    }
   
   void testConstraintsTitleSize() {
	   hotel = new Hotel(title:'q ',adress:"Sennaya str",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	   assertFalse hotel.validate()
	   assertEquals 'size', hotel.errors['title']

	   hotel = new Hotel(title:'fdvsdsdfvksdfnvkshbvgiusebruvsbjkbdnmbvairebhvgaiuebnvjkbsluibrhdvkjdn',adress:"Sennaya str",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	   assertFalse hotel.validate()
	   assertEquals 'size', hotel.errors['title']

	   hotel = new Hotel(title:'Hotel Spa',adress:"Sovetckaya street",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	   assertTrue hotel.validate()
   }
   
   void testConstraintsAdressSize() {
	   hotel = new Hotel(title:'Hotel ',adress:"q",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	   assertFalse hotel.validate()
	   assertEquals 'size', hotel.errors['title']

	   hotel = new Hotel(title:'Hotel R',adress:"fdvsdsdfvksdfnvkshbvgiusebruvsbjkbdnmbvairebhvgaiuebnvjkbsluibrhdvkjdn",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	   assertFalse hotel.validate()
	   assertEquals 'size', hotel.errors['title']

	   hotel = new Hotel(title:'Hotel Spa',adress:"Sovetckaya street",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	   assertTrue hotel.validate()
   }   
   
   void testConstraintsWebSiteBlank() {
	   hotel = new Hotel(title:'Hotel D',adress:"Sovetckaya street",website:" ",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	   assertFalse hotel.validate()
	   assertEquals 'blank', hotel.errors['website']

	   hotel = new Hotel(title:"Hotel Anna",adress:"Sovetckaya street",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	   assertTrue hotel.validate()
   }
  
  void testConstraintsWebSiteSize() {
	  hotel = new Hotel(title:'Hotel Q ',adress:"Sennaya str",website:"ww",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	  assertFalse hotel.validate()
	  assertEquals 'size', hotel.errors['title']

	  hotel = new Hotel(title:'Hotel L',adress:"Sennaya str",website:"sdfasf,asdnfljkadnfgruiehqpgieuryt7894yqhgjidfhgiadfhgajkldfhgkjadfgkhaf",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	  assertFalse hotel.validate()
	  assertEquals 'size', hotel.errors['title']

	  hotel = new Hotel(title:'Hotel Spa',adress:"Sovetckaya street",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	  assertTrue hotel.validate()
  }  
  
  void testConstraintsDescriptionBlank() {
	  hotel = new Hotel(title:'Hotel D',adress:"Sovetckaya street",website:"www.someWeb.ru",description:"", dateCreated: new Date("2012/03/4"))
	  assertFalse hotel.validate()
	  assertEquals 'blank', hotel.errors['description']

	  hotel = new Hotel(title:"Hotel Anna",adress:"Sovetckaya street",website:"www.someWeb.ru",description:"Hotel description", dateCreated: new Date("2012/03/4"))
	  assertTrue hotel.validate()
  }
  
  void testConstraintsStartDateNullable() {
	  hotel.dateCreated = null
	  assertTrue hotel.validate()
	  assertNull hotel.errors['dateCreated']
  }  */
  
  
  
}
